package com.app.GoCuro.data;

import android.os.Parcel;
import android.os.Parcelable;

@SuppressWarnings("serial")
public class InputItem implements Parcelable  {
	private String createDatetime;
	private String modifyDatetime;
	private String itemName;
	private String quantity;
	private String barcode;
	
	
	public InputItem(String createDatetime, String modifyDatetime, String itemName, String quantity, String barcode)
	{
		this.createDatetime = createDatetime;
		this.modifyDatetime = modifyDatetime;
		this.itemName = itemName;
		this.quantity = quantity;
		this.barcode = barcode;
	}
	
	public InputItem(Parcel in){
		String[] data = new String[5];
		  
		in.readStringArray(data);
		this.createDatetime = data[0];
		this.modifyDatetime = data[1];
		this.itemName = data[2];
		this.quantity = data[3];
		this.barcode = data[4];
	}
	
	public String getCreateDateTime()
	{
		return createDatetime;
	}
	
	public String getModifiedDateTime()
	{
		return modifyDatetime;
	}
	
	public String getItemName()
	{
		
		return itemName;
	}
	
	public String getQuantity()
	{
		return quantity;
	}
	
	public String getBarcode()
	{
		return barcode;
	}
	
	@Override
	public String toString(){
		if(modifyDatetime.isEmpty()){
			return "Created: " + createDatetime + '\n' + 
					"Modified: " + "Never" + '\n' +
					   "Name: " + itemName  + '\n' + 
					   "Quantity: " + quantity +  '\n' +
				       "Barcode: " + barcode;
		}
		else{
			return "Created: " + createDatetime + '\n' + 
					"Modified: " + modifyDatetime + '\n' +
					   "Name: " + itemName  + '\n' + 
					   "Quantity: " + quantity +  '\n' +
				       "Barcode: " + barcode;
			
		}
		
		
	}

	 public static final Parcelable.Creator<InputItem> CREATOR = new Creator<InputItem>() {  
		  
        @Override  
        public InputItem createFromParcel(Parcel source) {  
            return new InputItem(source);  
        }  
  
        @Override  
        public InputItem[] newArray(int size) {  
            return new InputItem[size];  
        }  
    };  
	
	
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
        dest.writeStringArray(new String[] {this.createDatetime,
        									this.modifyDatetime,
        		                            this.itemName,
        		                            this.quantity,
        		                            this.barcode});
	}
	
	
}
